package com.xbfinal.oss.controller;

import com.xbfinal.commonUtils.Result;
import com.xbfinal.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Title: OssController
 * @Author 笑霸fianl
 * @Package com.xbfinal.oss.controller
 * @Date 2023/1/2 17:05
 * @描述:
 */
@Api("OSS文件操作")
@Slf4j
@RestController
@RequestMapping("/eduoss/fileoss")
public class OssController {


    @Autowired
    private OssService ossService;
    /**
     * 上传头像的方法
     */
    @ApiOperation("上传头像的方法")
    @PostMapping("uploadOssFile")
    public Result uploadOssFile(MultipartFile file){
        //获取文件 MultipartFile MultipartFile

        log.info("上传头像的方法");
        //返回图片的路径，数据库存的是路径
        String url = ossService.uploadFileAvatar(file);
        return Result.ok().add("url",url);
    }
}
